home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
zbpc_460.zip
/
UTILITY.EXE
/
STRINPUT.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-03-27
|
3KB
|
90 lines
Length%=40 'Length of input field
XOrigin%=10 'Column position to accept input
YOrigin%=10 'Row position to accept input
InputMask$=STRING$(Length%,32) 'Initialize input string to --- try 177
Mask$=CHR$(32) 'Filler for backspace, should be the same value as above
Position%=1 'Position in the field to begin the edit, usually the left
Insert%=1 'Toggles start-up state of insert, 1 is insert on, 6 is off
COLOR,31:CLS
PRINT@(XOrigin%,YOrigin%)InputMask$;
"CheckKey" 'Look for input, report in KeyValue$
LOCATEXOrigin%+Position%-1,YOrigin%,1,Insert%,7
KeyValue$=INKEY$
IFKeyValue$=""GOTO"CheckKey"
Code$="" 'Determine if regular or special key input
IFLEN(KeyValue$)=2Code$=RIGHT$(KeyValue$,1)
LONGIF Code$="" 'Process regular keys
LONGIFKeyValue$=CHR$(8) 'handle backspace
MID$(InputMask$,Position%,1)=Mask$
IFPosition%>1Position%=Position%-1
ENDIF
'Terminate input routine with ENTER key and return Result$
IFKeyValue$=CHR$(13)Result$=InputMask$:END
'Overwrite old information, change to 48 and 57 to
'to restrict input to numeric
LONGIFASC(KeyValue$)>31ANDASC(KeyValue$)<127ANDInsert%=6
MID$(InputMask$,Position%,1)=KeyValue$:Position%=Position%+1
IFPosition%>Length%Position%=Position%-1
ENDIF
'Insert information, change to 48 and 57 to
'to restrict input to numeric
LONGIFASC(KeyValue$)>31ANDASC(KeyValue$)<127ANDInsert%=1
Temp$=RIGHT$(InputMask$,Length%-Position%+1):X%=LEN(Temp$)
MID$(InputMask$,Position%+1,X%)=Temp$
MID$(InputMask$,Position%,1)=KeyValue$:Position%=Position%+1
IFPosition%>Length%Position%=Position%-1
ENDIF
XELSE 'Handle special keys
'Terminate input, return Result$ and move up one line
'for another input with UP arrow
IFCode$=CHR$(72)YOrigin%=YOrigin%-1:Result$=InputMask$:GOTO"NewLine"
'Terminate input, return Result$ and move up down line
'for another input with DOWN arrow
IFCode$=CHR$(80)YOrigin%=YOrigin%+1:Result$=InputMask$:GOTO"NewLine"
'HOME key to go to beginning of input line
IFCode$=CHR$(71)Position%=1
'END key to go to end of input line
IFCode$=CHR$(79)Position%=Length%
'Move cursor left with LEFT ARROW key
IFCode$=CHR$(75)Position%=Position%-1:IFPosition%=0Position%=1
'Move cursor right with RIGHT ARROW key
IFCode$=CHR$(77)Position%=Position%+1:IFPosition%>Length%Position%=Length%
'DELETE key to delete character and shift remaining characters
'left one position, padding end of input line with Mask$
LONGIFCode$=CHR$(83)
Temp$=RIGHT$(InputMask$,Length%-Position%)+Mask$
MID$(InputMask$,Position%,Length%-Position%)=Temp$
ENDIF
'Toggle state of INSERT key
LONGIFCode$=CHR$(82)
IFInsert%=6THENInsert%=1ELSEInsert%=6
ENDIF
ENDIF
'Display edited input line
PRINT@(XOrigin%,YOrigin%)LEFT$(InputMask$,Length%);
GOTO"CheckKey"
'Initialize new input line
"NewLine"
Length%=40:InputMask$=STRING$(Length%,32):Position%=1:GOTO"CheckKey"